#include<vector>
#include<iostream>
#include<algorithm>
using std::vector;

class Solution {
public:
    vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
        std::sort(candidates.begin(), candidates.end());
        vector<vector<int>> result;
        vector<int> combination;
        this->dfs(result, combination, candidates, target, 0);
        return result;
    }

    void dfs(vector<vector<int>>& results, vector<int>& combination, vector<int> candidates, int target, int idx) {
        if (target == 0) {
            results.push_back(combination);
            return;
        }
        for (int i = idx; i < candidates.size(); i++) {
            if (target < candidates[i]) break;
            combination.push_back(candidates[i]);
            this->dfs(results, combination, candidates, target-candidates[i], i);
            combination.pop_back();
        }
    }
};


int main() {
    vector<int> input = {};
    int n;
    while (std::cin >> n) {
        input.push_back(n);
    }
    std::cout << "input: \n";
    for (auto k: input) std::cout << k << " ";
    std::cout << "\n";
    

    auto res = Solution().combinationSum(input, 7);
    std::cout << "result is below \n";
    for (auto p : res) {
        for (auto n : p) {
            std::cout << n << ",";
        }
        std::cout << "\n";
    }
    return 0;


}